package stti.util;

import java.util.ArrayList;
import java.util.List;

public class EnvioEmail {

	private List<String> destinatarios = new ArrayList<String>();
	private List<String> cc = new ArrayList<String>();
	private List<String> bcc = new ArrayList<String>();
	private String asunto = "";
	private String cuerpo = "";
	
	public EnvioEmail()
	{
		this.destinatarios = new ArrayList<String>();
		this.bcc = new ArrayList<String>();
		this.cc  = new ArrayList<String>();
		this.asunto = "";
		this.cuerpo = "";
	}
	
	public void setAsunto(String asunto)
	{
		this.asunto = asunto;
	}
	
	public void setCuerpo(String cuerpo)
	{
		this.cuerpo = cuerpo;
	}
	
	public String getAsunto()
	{
		return this.asunto;
	}
	
	public String getCuerpo()
	{
		return this.cuerpo;
	}
	
	public void addDestinatario(String destinatario)
	{
		boolean existe = false;
		for (int i = 0; i < destinatarios.size(); i++)
		{
			if (destinatarios.get(i).trim().toUpperCase().contentEquals(destinatario.toUpperCase()))
			{
				existe = true;
			}
		}
		if (!existe)
		{
			destinatarios.add(destinatario);
		}
	}

	public void addCC(String destinatario)
	{
		boolean existe = false;
		for (int i = 0; i < cc.size(); i++)
		{
			if (cc.get(i).trim().toUpperCase().contentEquals(destinatario.toUpperCase()))
			{
				existe = true;
			}
		}
		if (!existe)
		{
			cc.add(destinatario);
		}
	}	

	public void addBCC(String destinatario)
	{
		boolean existe = false;
		for (int i = 0; i < bcc.size(); i++)
		{
			if (bcc.get(i).trim().toUpperCase().contentEquals(destinatario.toUpperCase()))
			{
				existe = true;
			}
		}
		if (!existe)
		{
			bcc.add(destinatario);
		}
	}
	
	public String[] getDestinatarios()
	{
		String[] dest = new String[destinatarios.size()];
		for (int i = 0; i < destinatarios.size(); i++)
		{
			dest[i] = destinatarios.get(i);
		}
		return dest;
	}

	public String[] getCC()
	{
		String[] dest = new String[cc.size()];
		for (int i = 0; i < cc.size(); i++)
		{
			dest[i] = cc.get(i);
		}
		return dest;
	}

	public String[] getBCC()
	{
		String[] dest = new String[bcc.size()];
		for (int i = 0; i < bcc.size(); i++)
		{
			dest[i] = bcc.get(i);
		}
		return dest;
	}
	
	public String preview()
	{
		String  pw = "";
		pw = "Para: ";
		for (int i = 0; i < destinatarios.size(); i++)
		{
			if (i > 0)
			{
				pw = pw + "; ";
			}
			pw = pw + destinatarios.get(i);
		}
		pw = pw + "\nCC: ";
		for (int i = 0; i < cc.size(); i++)
		{
			if (i > 0)
			{
				pw = pw + "; ";
			}
			pw = pw + cc.get(i);
		}
		pw = pw + "\nBCC: ";
		for (int i = 0; i < bcc.size(); i++)
		{
			if (i > 0)
			{
				pw = pw + "; ";
			}
			pw = pw + bcc.get(i);
		}
		pw = pw + "\nAsunto: "+this.asunto;
		pw = pw + "\nCuerpo: \n"+this.cuerpo;
		
		return pw;
	}
	
	public boolean enviarCorreo()
	{
		boolean status = false;
		
		return status;
	}
}
